package main

import (
	"bufio"
	"fmt"
	"os"
)

func write() {
	fileObj, err := os.OpenFile("./1.txt", os.O_WRONLY|os.O_CREATE, 0644)
	if err != nil {
		fmt.Printf("open file err")
	}
	wr := bufio.NewWriter(fileObj)
	_, wErr := wr.WriteString("hello world \n")
	if wErr != nil {
		fmt.Println("write cache file failed")
	}
	fErr := wr.Flush() // 将缓存内容写入文件
	if fErr != nil {
		fmt.Println("cache file write failed")
	}
	fileObj.Close()
}
func main() {

	write()
}
